<template>
    <PanelBox :image="image">
        <div class="tailing-pond-box">
            <BPie class="pie-box-right" :data="dataList" :sum="sum" />
            <div class="line-box-right">
                <BBar
                    class="line-small-right"
                    v-for="(item, index) in dataList"
                    :key="index"
                    :name="item.name"
                    :value="item.value"
                    :sum="sum"
                    :color="item.color"
                />
            </div>
        </div>
    </PanelBox>
</template>

<script>
import PanelBox from "@/component/PanelBox";
import BPie from "@/view/home/component/TheLeft/component/component/BPie";
import BBar from "@/view/home/component/TheLeft/component/component/BBar";
import { FetchGetTailingLocalDistribution } from "@/api";

export default {
    name: "TailingPond",

    components: {
        PanelBox,
        BBar,
        BPie,
    },

    props: {
        image: {
            type: String,
            default() {
                return "";
            },
        },
    },

    data() {
        return {
            dataList: [
                // {
                //     name: "泉州",
                //     value: 1,
                //     color: "#CB95FB",
                // },
                // {
                //     name: "龙岩",
                //     value: 3,
                //     color: "#BFFF3F",
                // },
                // {
                //     name: "三明",
                //     value: 1,
                //     color: "#4C67FF",
                // },
            ],
            sum: 0,
        };
    },

    created() {
        this.refreshList();
    },

    methods: {
        refreshList() {
            FetchGetTailingLocalDistribution().then((res) => {
                this.dataList = res.map((item) => ({
                    name: item.areaName,
                    value: item.count,
                }));
                this.sum = eval(res.map((item) => item.count).join("+"));
            });
        },
    },
};
</script>

<style lang="scss" scoped>
.tailing-pond-box {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .pie-box-right {
        width: 60%;
        height: 100%;
    }
    .line-box-right {
        width: 60%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        align-items: flex-start;
        .line-small-right {
            width: 90%;
            height: .13rem;
        }
    }
}
</style>
